package com.netease.pris.activity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import com.netease.framework.k;
import com.netease.pris.activity.view.PRISGridView;
import com.netease.pris.activity.view.RelativeLayoutEx;
import com.netease.pris.atom.g;
import com.netease.pris.atom.u;
import com.netease.pris.v;
import java.util.HashMap;
import java.util.LinkedList;

public class cr extends BaseAdapter
{
  private HashMap b = new HashMap();
  private com.netease.pris.activity.view.d c = new aw(this);

  public cr(MainGridActivity paramMainGridActivity)
  {
  }

  private void a(View paramView, u paramu, int paramInt1, int paramInt2)
  {
    if (paramView == null)
      throw new RuntimeException("invalid input");
    if (MainGridActivity.L(this.a) == null)
      MainGridActivity.a(this.a, BitmapFactory.decodeResource(this.a.getResources(), 2130837809));
    RelativeLayoutEx localRelativeLayoutEx = (RelativeLayoutEx)paramView;
    localRelativeLayoutEx.a(MainGridActivity.L(this.a));
    ImageView localImageView1 = (ImageView)paramView.findViewById(2131558564);
    ImageView localImageView2 = (ImageView)paramView.findViewById(2131558565);
    TextView localTextView = (TextView)paramView.findViewById(2131558566);
    a(localRelativeLayoutEx, localImageView1, localImageView2, localTextView);
    if (paramu.V().equals("-1"))
    {
      localTextView.setVisibility(8);
      localImageView2.setVisibility(8);
      localImageView1.setTag(null);
      localImageView1.setScaleType(ImageView.ScaleType.CENTER);
      localImageView1.setImageDrawable(k.a(this.a).b(2130837508));
      localImageView1.setBackgroundColor(k.a(this.a).c(2131230960));
      MainGridActivity.a(this.a, localImageView1);
      localRelativeLayoutEx.a(false);
      localRelativeLayoutEx.invalidate();
    }
    String str1;
    label320: int i;
    int j;
    while (true)
    {
      return;
      localTextView.setVisibility(0);
      localImageView1.setScaleType(ImageView.ScaleType.CENTER_CROP);
      localRelativeLayoutEx.a(paramu.t());
      localRelativeLayoutEx.invalidate();
      if (MainGridActivity.a(this.a, paramu))
      {
        localImageView2.setImageResource(2130837823);
        localImageView2.setVisibility(0);
      }
      while (true)
      {
        localTextView.setText(paramu.U());
        str1 = paramu.b(g.f);
        if (str1 != null)
          break label320;
        localImageView1.setImageDrawable(null);
        localImageView1.setBackgroundColor(Color.rgb(225, 225, 225));
        break;
        localImageView2.setImageDrawable(null);
        localImageView2.setVisibility(8);
      }
      i = this.a.c();
      j = this.a.b();
      Bitmap localBitmap1 = com.netease.image.d.a().a(str1, 2, i, j);
      if (localBitmap1 == null)
        break;
      localImageView1.setImageBitmap(localBitmap1);
    }
    String str2 = paramu.y();
    Bitmap localBitmap2 = com.netease.image.d.a().a(str2, 2, this.a.c(), this.a.b());
    if (localBitmap2 != null)
      localImageView1.setImageBitmap(localBitmap2);
    while (true)
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localImageView1.setTag(localStringBuilder);
      com.netease.image.d.a().a(localStringBuilder, 2, str1, new ax(this, localImageView1), i, j, paramInt2, paramInt1);
      break;
      localImageView1.setImageDrawable(null);
    }
  }

  private void a(RelativeLayoutEx paramRelativeLayoutEx, ImageView paramImageView1, ImageView paramImageView2, TextView paramTextView)
  {
    if (paramRelativeLayoutEx != null)
      paramRelativeLayoutEx.a(false);
    if (paramImageView1 != null)
    {
      paramImageView1.setImageDrawable(null);
      paramImageView1.setBackgroundDrawable(null);
    }
    if (paramImageView2 != null)
    {
      paramImageView2.setImageDrawable(null);
      paramImageView2.setBackgroundDrawable(null);
    }
    if (paramTextView != null)
      paramTextView.setText("");
  }

  public int a()
  {
    return MainGridActivity.c(this.a).size();
  }

  public int a(int paramInt)
  {
    if ((paramInt < 0) || (paramInt >= getCount()))
      throw new RuntimeException("invalid position");
    Integer localInteger = (Integer)this.b.get(Integer.valueOf(paramInt));
    if (localInteger == null)
    {
      int i = v.b();
      this.b.put(Integer.valueOf(paramInt), Integer.valueOf(i));
      localInteger = Integer.valueOf(i);
    }
    return localInteger.intValue();
  }

  public int a(u paramu)
  {
    if ((paramu == null) || (MainGridActivity.c(this.a) == null));
    for (int i = -1; ; i = MainGridActivity.c(this.a).indexOf(paramu))
      return i;
  }

  public View a(int paramInt1, ViewGroup paramViewGroup, View paramView, int paramInt2, int paramInt3)
  {
    u localu = (u)getItem(paramInt1);
    if (localu == null)
      throw new RuntimeException("entry got at position: " + paramInt1 + " is null!");
    if ((paramView != null) && (paramView.getTag() != null) && (MainGridActivity.K(this.a)) && (((String)paramView.getTag()).equals(localu.V())));
    while (true)
    {
      return paramView;
      if (paramView == null)
        paramView = this.a.getLayoutInflater().inflate(2130903090, null);
      a(paramView, localu, paramInt2, paramInt3);
      paramView.setTag(localu.V());
    }
  }

  public void a(int paramInt, String paramString, View paramView)
  {
    if ((paramView == null) || (paramInt < 0) || (paramInt >= a()) || (TextUtils.isEmpty(paramString)));
    while (true)
    {
      return;
      Object localObject = getItem(paramInt);
      if (localObject == null)
        continue;
      u localu = (u)localObject;
      if (!(paramView instanceof RelativeLayoutEx))
        continue;
      ((RelativeLayoutEx)paramView).a(localu.t());
    }
  }

  public int getCount()
  {
    if (MainGridActivity.c(this.a).size() % 6 > 0);
    for (int i = 1 + MainGridActivity.c(this.a).size() / 6; ; i = MainGridActivity.c(this.a).size() / 6)
      return i;
  }

  public Object getItem(int paramInt)
  {
    return MainGridActivity.c(this.a).get(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    PRISGridView localPRISGridView1;
    if ((paramView == null) || (!(paramView instanceof PRISGridView)))
    {
      localPRISGridView1 = (PRISGridView)this.a.getLayoutInflater().inflate(2130903050, null);
      localPRISGridView1.a(this);
      localPRISGridView1.a(8);
      localPRISGridView1.b(8);
      localPRISGridView1.a(this.c);
      localPRISGridView1.a(this.a.A);
      localPRISGridView1.a(MainGridActivity.J(this.a));
    }
    for (PRISGridView localPRISGridView2 = localPRISGridView1; ; localPRISGridView2 = (PRISGridView)paramView)
    {
      localPRISGridView2.d(paramInt);
      return localPRISGridView2;
    }
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.activity.cr
 * JD-Core Version:    0.6.0
 */